//============================================================================
// Name        :  SpellChecker.h
// Authors     :  Paulo Faria Reis
//                Ana Zaiat
// Version     :  1.0
// Date        :  17 May 2012 - 30 May 2012
// Copyright   :  Academic work - MIT License
// Description :  Spell Checker Application.
//============================================================================

#ifndef SPELLCHECKER_H_
#define SPELLCHECKER_H_

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <string>
#include <fstream>
#include <strstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <ctime>

using namespace std;

struct option{
	string opt;
	int dist;
};


class SpellChecker {
public:
	SpellChecker(string fname, string dict);
	virtual ~SpellChecker();
	/* approximateStringMatching:
	 * Main algorithm for approximate string matching.
	 * Searches for the given word (toSearch) in the dictionary (dicWords) and adds results to options
	 * If exact match is found, returns true, else false.
	 *
	 * */
	bool approximateStringMatching(vector<string> & dicWords, char* toSearch, vector<option/*string*/> & options);
	/* ReadFile:
	 * Reads file to check (fname) word by word and outputs options found in dictionary (dict).
	 * Makes a copy of file content with marked words containing errors and options for correction.
	 * */
	void ReadFile(string fname, string dict);
	/* processDictionary:
	 * Processes dictionary (dicName) and copies all words to a vector dicWords
	 * */
	void processDictionary(string dicName, vector<string> & dicWords);
	/* ui:
	 * User interface
	 * */
	void ui();
	int wordsCounter;

private:
	string fileToCheck;
	string dictionary;  // eng or pt
	bool debug;
};

#endif /* SPELLCHECKER_H_ */

